rm(list=ls())

##############################################################################
# APPENDIX B6 TABLE 1
##############################################################################

# load packages
#library(texreg)
#library(mice)

# load data 
load("data/eurepoc_year_attacks.RData")
load("data/imputed_data_year.RData")

##############
# RUN MODELS #
##############

#model 1 (eurepoc attacks incidents)
m1 <- lm(attacks ~ treat + factor(ccode) + factor(spell), data = eurepoc_year_data)

#model 2 (eurepoc attacks control)
d.long$log_tech_articles <- log(d.long$tech_articles + 1)

imp.candidates <- as.mids(d.long)

fit.A <- with(imp.candidates, lm(attacks ~ treat + factor(ccode) + factor(spell) + 
                                   internet_usage + ict_exports + log_tech_articles))
m2 <- pool(fit.A)

################
# CREATE TABLE #
################
appendB6_tab1 <- screenreg(list(m1, m2), custom.coef.map = list("treat" = "candidate", 
                                            "internet_usage" = "internet usage", 
                                            "ict_exports" = "ICT exports", 
                                            "log_tech_articles" = "log tech articles"),
       omit.coef = c("country_spell"),
       custom.gof.rows = list("Country FE" = c("YES", "YES"), "Spell FE" = c("YES", "YES")), 
       digits = 3, stars = c(0.001, 0.01, 0.05, 0.1))

print(appendB6_tab1)

# script complete message 
print("appendB6_tab1 complete")




